# +_+ coding:utf-8 +_+

import ticker
import limitprice
import usd2cny
import depth
import kline

__author__ = 'cz'


class API(object):
    def __init__(self):
        print "API"

    @staticmethod
    def usd2cnyrate():
        return usd2cny.query()

    @staticmethod
    def ticker():
        t = ticker.query()
        print "    hight:", t.high
        print "    low:", t.low
        return t

    @staticmethod
    def limit_price():
        p = limitprice.query()
        if p is None:
            return
        r = usd2cny.query()
        print "    hight price:", p.high*r
        print "    low price", p.low*r

    @staticmethod
    def depth():
        d = depth.query()
        if d is None:
            return
        print "    asks:", d.ask
        print "    bids:", d.bid
        return d

    @staticmethod
    def kline():
        kl = kline.query()
        if kl is None:
            return
        r = usd2cny.query()
        kl.high *= r
        kl.low  *= r
        kl.end  *= r
        kl.start*= r
        return kl